#!/usr/bin/env python3
import os
import sys

sys.path.append("..")
sys.path.append("D:\\cdsswkspace\\medical-knowledge-graph\\mysite")

def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    
    # 检查是否指定了 runserver 命令，若没有则添加默认参数
    if len(sys.argv) > 1 and sys.argv[1] == 'runserver':
        # 确保提供了地址和端口
        if len(sys.argv) == 2:
            sys.argv.append('0.0.0.0:8086')
    elif len(sys.argv) == 1:
        # 默认启动开发服务器
        sys.argv.extend(['runserver', '0.0.0.0:8086'])
    
    execute_from_command_line(sys.argv)

if __name__ == '__main__':
    main()